﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using ReseWCF;

namespace Resehantering
{
    public partial class boss : System.Web.UI.Page
    {

        private GridView myGrid = null;
        
        protected override void OnPreRender(EventArgs e)
        {
            fillGridView();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
          
        }

        protected void btnGodkann_Click(object sender, EventArgs e)
        {
            
            ServiceReference1.Service1Client wcfClient = new ServiceReference1.Service1Client();
            
            short getIt = 0;
            getIt = (short) Convert.ToInt32(drop.SelectedItem.Text);

            wcfClient.UpdateResa(getIt);
        }

        public void fillGridView()
        {
           
                ContentPlaceHolder cont1 = (ContentPlaceHolder)Master.FindControl("MainContent");
                //ContentPlaceHolder cont3 = (ContentPlaceHolder)Master.FindControl("cont3");
                ServiceReference1.Service1Client wcfClient = new ServiceReference1.Service1Client();
                List<Resa> resor = wcfClient.GetResor();

                IEnumerable<Resa> IEprods = resor;

                myGrid = new GridView();

                myGrid.DataSource = IEprods;

                BoundField value = new BoundField();
                value.DataField = "ResaID";
                myGrid.Columns.Add(value);


                /* CheckBoxField check = new CheckBoxField();
                check.DataField = "godkand";
                check.ReadOnly = false;
                check.Visible = true;
                check.HeaderText = "MinCheckBox";
            

                myGrid.Columns.Add(check); */



                myGrid.DataBind();

                myGrid.HeaderRow.Cells[0].Visible = false;
                myGrid.HeaderRow.Cells[4].Visible = false;
                foreach (GridViewRow gvr in myGrid.Rows)
                {
                    gvr.Cells[0].Visible = false;
                    gvr.Cells[4].Visible = false;

                }
                griddiv.Controls.Add(myGrid);

                List<Resa> nyLista = new List<Resa>();
                foreach (Resa res in resor)
                {
                    if (res.Godkand == false)
                    {
                        nyLista.Add(res);
                    }

                }

                IEnumerable<Resa> IEprods2 = nyLista;



                drop.DataSource = IEprods2;
                drop.DataValueField = "ResaID";
                drop.DataBind();

                // goddiv.Controls.Add(drop);
            
         
        }

        
    }
}